<script setup>
import {ref} from 'vue'

import {computed} from "vue";

let props = defineProps({
  aaa:{
    type:Number,
    default:0
  }
})

let emit = defineEmits(["update:aaa"]);

let inputNumber = ref([]);
for (let i = 0; i < 10; i++) {
  inputNumber.value.push(0)
}

let totalNum = computed(function (){
  let total =  getSum();
  emit("update:aaa",total)
  return total;
})

function getSum(){
  let total = 0;
  for(let i=0; i<inputNumber.value.length; i++){
    total += (inputNumber.value[i] - 0);
  }
  return total;
}

function changeHandle(i){
  console.log(inputNumber);
}
</script>

<template>
  <div v-for="i in inputNumber">
    <input type="text" v-model=inputNumber[i] />
  </div>
<div>
  合计：{{totalNum}}
</div>
</template>

<style scoped>

</style>